import { useNavigate } from 'react-router-dom'

/**
 * 跳转类
 *  每一个方法的 from参数 就是 从哪个路由跳转过来的 格式为 home | home/xxx | home/xxx/xxx 意思就是开头不需要/
 */
type fromType = {
  from?: string
}
export class GotoPage {
  navigateTo = useNavigate()
  // 个人中心
  public gotoMy(from: fromType) {
    this.navigateTo('/my', { state: from })
  }
  // 编辑资料
  public gotoEdit(from: fromType) {
    this.navigateTo('/edit', { state: from })
  }
  // 登陆页面
  public gotoLogin(from: fromType) {
    this.navigateTo('/login', { state: from })
  }
  // 登陆注册
  public gotoRegister(from: fromType) {
    this.navigateTo('/register', { state: from })
  }
  // 考试页面
  public gotoExam(from: fromType, flag: 1) {
    console.log(from)

    this.navigateTo('/exam?flag=' + flag, { state: from })
  }
}
